﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using ProtocolVN.Framework.Core;
using System.Data.Common;

namespace ProtocolVN.Framework.Win
{
    public class HelpDAPhieu
    {
        #region GetDAPhieuID
        //PHUOCNC: Cua DA hiện tại
        //public static long GetPhieuID(DataSet ds)
        //{
        //    if ((ds.Tables[0].Rows.Count == 0 ||
        //        ds.Tables[0].Rows[0][0].ToString() == "") &&
        //        ds.Tables[0].Rows[0].RowState != DataRowState.Deleted)
        //        return -1;
        //    else
        //        if (ds.Tables[0].Rows[0].RowState != DataRowState.Deleted)
        //            return HelpNumber.ParseInt64(ds.Tables[0].Rows[0][0]);
        //    return -1;
        //}

        public static long GetPhieuID(DataSet ds)
        {
            long ret = -1;
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                if (row.RowState != DataRowState.Deleted) 
                {
                    ret = HelpNumber.ParseInt64(row[0]);
                    if (ret <= 0)
                    {
                        ret = -1;
                    }
                    else break;
                   
                }               
            }
            ds.Clear();
            return ret;
        }
      
        #endregion
        
    }
}
